Skip to content

[12.x] Add Request input contextual attributes #56217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: 12.x
Choose a base branch
from

Conversation

ziadoz
Copy link
Contributor

@ziadoz ziadoz commented Jul 4, 2025

This PR adds #[Query], #[Input] and #[Post] contextual attributes, similar to #[Route(...)], that allow GET or POST data to be retrieved from the current request.

They can be used to populate a data object:

final readonly class SearchData
{
    public function __construct(
        #[Query('query')] public string $query,
        #[Query('order', 'asc')] public string $order,
    ) {}
}

Route::get('/', function (SearchData $data) {
    dump($data);
});

Or pass an input field directly to a controller:

Route::post('/post/status', function (Post $post, #[Post('status')] $status) {
    $post->update(['status' => $status]);
});

Copy link

github-actions bot commented Jul 4, 2025

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@ziadoz ziadoz changed the title [12.x] Add Request Get/Post Contextual Attributes [12.x] Add Request input contextual attributes Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant